package tcp;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Socket;

public class DateClient {
    public static void main(String[] args) {
        try {
            // 与服务端socket进行连接
            // 需要指定服务器ip地址
            // 服务器/客户机端口一对一
            System.out.println("to be connecting to server");
            Socket sock = new Socket("192.168.1.3", 9000);
            System.out.println("success to connect to server");

            InputStream in = sock.getInputStream();
            BufferedReader bin = new BufferedReader(new InputStreamReader(in));

            // 读取来自socket的信息
            String line;
            while ((line = bin.readLine()) != null) {
                System.out.println(line);
            }
            sock.close();

        } catch (IOException ioe) {
            System.out.println(ioe);
        }
    }
}
